/*
 * @Author: szx
 * @Date: 2022-04-28 13:06:46
 * @LastEditTime: 2022-04-28 13:14:39
 * @Description:
 * @FilePath: \leetcode\900-999\905\905.js
 */
/**
 * @param {number[]} nums
 * @return {number[]}
 */
var sortArrayByParity = function (nums) {
    let i = 0,
        j = nums.length - 1;
    while (i < j) {
        if (nums[i] & 1) {
            [nums[i], nums[j]] = [nums[j], nums[i]];
            j--;
        } else i++;                
    }
    return nums;
};
